package cn.school.thoughtworks.section2;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PracticeB {
    Map<String, Integer> countSameElements(List<String> collection1) {
        Map<String, Integer> nameMap = new HashMap();

        collection1.forEach(name -> nameMap.compute(name, (k, v) -> v == null ? 1 : ++v));
        return nameMap;


    }
}
